#ifndef __NamcoSystem1MMU_h__
#define __NamcoSystem1MMU_h__

#define BANK_READ			1
#define BANK_WRITE		2
#define BANK_READFUNC	4
#define BANK_WRITEFUNC	8

typedef u8 (*BankReadFunc)(void*,u32);
typedef void (*BankWriteFunc)(void*,u32,u8);

class CSystem1Machine;
class CNamcoSystem1MMU
	{
	protected:
		u32 BankReg[8];
		u8 *BankPtr[8];
		u8 BankType[8];
		BankReadFunc BankRead[8];
		BankWriteFunc BankWrite[8];
	public:
		CSystem1Machine *Owner;
		u8 *RAMPtr;
		char Name[32];
	protected:
		void MapBank(int bank,u32 data);		//map bank in address space
		//functions used with bankswitching
		static u8 BankReadSpriteRAM(void *user,u32 addr);
		static void BankWriteSpriteRAM(void *user,u32 addr,u8 data);
		static u8 BankReadSoundRAM(void *user,u32 addr);
		static void BankWriteSoundRAM(void *user,u32 addr,u8 data);
		static u8 BankReadPaletteRAM(void *user,u32 addr);
		static void BankWritePaletteRAM(void *user,u32 addr,u8 data);
		static u8 BankReadKeyChip(void *user,u32 addr);
		static void BankWriteKeyChip(void *user,u32 addr,u8 data);
	public:
		CNamcoSystem1MMU(CSystem1Machine *O,u8 *R,char *n);
		~CNamcoSystem1MMU();
		void Reset();
		u8 Read(void *user,u32 addr);					//read from address mapped by the mmu
		void Write(void *user,u32 addr,u8 data);	//write to address mapped by mmu
		void Bankswitch(u32 addr,u8 data);			//perform bankswitch
	};

#endif
